package com.atguigu2.two.exer3;

/**
 * ClassName: reversal
 * Package: com.atguigu2.two.exer3
 * Description:
 *
 * @Author BuTang
 * @Create 2023/2/23 20:14
 * @Version 1.0
 */
public class reversal {
    public static void main(String[] args) {

        //方法一

        int[] arr = new int[]{1,2,3,4,5,6,7,8,9};
        /*for (int i = 0; i < arr.length/2; i++) {
            int temp = arr[i];
            arr[i]= arr[arr.length-1-i];
            arr[arr.length-1-i]=temp;
        }
        for (int i = 0; i <arr.length ; i++) {
            System.out.println(arr[i]);

        }

        */


        //方法二
        for (int i = 0,j = arr.length-1; i <j; i++,j--) {
            int temp = arr[j];
            arr[j] = arr[i];
            arr[i] = temp;
        }
        for (int i = 0; i <arr.length ; i++) {
            System.out.println(arr[i]);

        }

    }
}
